/*
 * networkedLocksTestFour.c
 *
 *  Created on: Jul 12, 2011
 *      Author: peckb1
 */

#include "syscall.h"


int sharedLockIdOne = -1;
int sharedCVIdOne   = -1;


void LockWaitHappyCaseSignaler() {
    CVSignal(sharedCVIdOne, sharedLockIdOne);

    Exit(0);
}


void LockWaitHappyCaseWaiterForSignal() {
    LockAcquire(sharedLockIdOne);

    Fork(&LockWaitHappyCaseSignaler, "Signaler", 8);

    CVWait(sharedCVIdOne, sharedLockIdOne);

    LockRelease(sharedLockIdOne);

    LockDestroy(sharedLockIdOne);

    CVDestroy(sharedCVIdOne);

    Exit(0);
}

int main() {
    sharedLockIdOne = CreateLock("Shared Lock One", 15);
    sharedCVIdOne   = CreateCV("Shared CV One", 13);

    Fork(&LockWaitHappyCaseWaiterForSignal,   "SignalWaiter", 12);

    Exit(0);
}
